#include<bits/stdc++.h>
#define mpr make_pair
#define sz(x) (int)(x.size())
using namespace std;
typedef pair<int,int> pii;
const int inf=2e9;
const int MAXN=100005;
struct Node{
    int d;
    int v;
    int a;
}v[MAXN];
int p[MAXN];
int res[MAXN];
int n,m,L,V;
int search(int ll){
    int pp=lower_bound(p+1,p+1+m,ll)-p;
    return pp;
}
void solve(){

    cin>>n>>m>>L>>V;
    for(int i=1;i<=n;i++){
        cin>>v[i].d>>v[i].v>>v[i].a;
    }
    for(int i=1;i<=m;i++){
        cin>>p[i];
        res[p[i]]=0;
    }
    res[m+1]=0;
    int cnt=0;
    for(int i=1;i<=n;i++){
        if(v[i].a==0){
            if(v[i].v>V){
                if(v[i].d>p[m]) continue;
                int x=search(v[i].d);
                res[x]++;
                cnt++;
            }
        }else if(v[i].a>0){
            int s=(V*V-v[i].v*v[i].v)/(2*v[i].a)+1;
            s+=v[i].d;
            int pp=max(s,v[i].d),q=p[m];
            if(pp>q) continue;
            int x=search(pp);
            if(p[x]>q||x>m) continue;
            res[x]++;
            cnt++;
        }else{
            int mn1=(V*V-v[i].v*v[i].v+2*v[i].a-1)/(2*v[i].a)-1;
            int mn2=-(v[i].v*v[i].v)/(2*v[i].a);
            mn1+=v[i].d;
            mn2+=v[i].d;
            int pp=v[i].d,q=min(mn1,mn2);
            if(pp>q) continue;
            int x=search(pp);
            if(p[x]>q||x>m) continue;
            res[x]++;
            cnt++;
        }
    }
    int ans=0;
    for(int i=1;i<=m;i++){
        ans+=(res[i]==0);
        cout<<res[i]<<" ";
    }
    cout<<endl;
    cout<<cnt<<" "<<ans<<endl;
}
int main(){
    freopen("detect.in","r",stdin);
    freopen("detect.out","w",stdout);
    int tt;
    cin>>tt;
    while(tt--){
        solve();
    }
    return 0;
}
